<template>
	<view class="mains">
		<u-popup :show="showLoginPop" mode="bottom" :round="10" @close="close">
			<mploginpopup></mploginpopup>
		</u-popup>
		<view class="heads">
			<view class="headmsg uniFlex" v-if="user.avatar" @click="upuser">
				<image :src="user.avatar" mode=""></image>
				<div>
					<view>{{user.nickname}}</view>
					<view class="phone">{{user.mobile}}</view>
				</div>
			</view>
			<view class="headmsg uniFlex" v-else @click="goLogin">
				<image src="@/static/mains/head.png" mode=""></image>
				<view>前往登录</view>
			</view>
		</view>
		
		<view class="contents">
			<view class="cont" @click="tabs(2)">
				<img src="@/static/mains/m1.png" alt="">
				<view>用户反馈</view>
			</view>
			<view class="cont" @click="tabs(3)">
				<img src="@/static/mains/m2.png" alt="">
				<view>反馈列表</view>
			</view>
			<view class="cont" @click="tabs(4)">
				<img src="@/static/mains/m3.png" alt="">
				<view>个人资料</view>
			</view>
			<view class="cont" @click="tabs(5)">
				<img src="@/static/mains/m4.png" alt="">
				<view>联系公司</view>
			</view>
			<view class="cont" @click="tabs(6)" v-if="wbshow">
				<img src="@/static/mains/m5.png" alt="">
				<view>负责电梯</view>
			</view>
			<view class="cont" @click="tabs(7)" v-if="wbshow">
				<img src="@/static/mains/m6.png" alt="">
				<view>维保记录</view>
			</view>
		</view>
	</view>
</template>

<script>
	import mploginpopup from '@/components/mplogin-popup/mplogin-popup.vue';
	export default {
		components: {
			mploginpopup
		},
		data() {
			return {
				showLoginPop: false,
				user:{
					avatar:'',
					nickname:'',
					mobile:''
				},
				wbshow:false
			}
		},
		onLoad() {

		},
		methods: {
			async getData() {
				console.log('我的')
				// let res = await this.$api.account({
				// 	account:'15256887307',
				// 	terminal:'1',
				// 	scene:'1',
				// 	password:'qq123456',
				// });
				// if(res.code == 1){
				// 	// console.log(res)
				// 	uni.setStorageSync('token',res.data.token);
				// }
				// console.log(uni.getStorageSync("token"))
				if(uni.getStorageSync("token")){
					this.getMsg()
				}
			},
			// 关闭
			close(){
				this.showLoginPop = false;
			},
			// 修改头像昵称
			upuser(){
				this.$nextTick(function(){
					this.showLoginPop = true;
				})
			},
			// 获取个人信息
			async getMsg(){
				let res = await this.$api.getcenter();
				if(res.code == 1){
					// console.log(res)
					this.user = res.data;
					if(res.data.wb){
						this.wbshow = true;
					}
				}
			},
			// 登录
			Login() {
				uni.showModal({
					title: '温馨提示',
					content: '您还未登录，请登录后操作！',
					cancelColor: '#B3B3B3',
					confirmText: '去登录',
					confirmColor: '#00A7FF',
					success: function(res) {
						if (res.confirm) {
							uni.reLaunch({
								url: '/pages/login/login'
							})
						} else if (res.cancel) {
			
						}
					}
				});
			},
			// 前往登录
			goLogin(){
				uni.navigateTo({
					url:'/pages/login/login'
				})
			},
			tabs(num){
				if(!uni.getStorageSync("token")){
					this.Login()
					return
				}
				if(num==2){
					uni.navigateTo({
						url:'/pages/mains/feedback/feedback'
					})
				}else if(num==3){
					uni.navigateTo({
						url:'/pages/mains/feedback/list'
					})
				}else if(num==4){
					uni.navigateTo({
						url:'/pages/mains/person/person'
					})
				}else if(num==5){
					uni.navigateTo({
						url:'/pages/mains/call/call'
					})
				}else if(num==6){
					uni.navigateTo({
						url:'/pages/mains/headup/headup'
					})
				}else if(num==7){
					uni.navigateTo({
						url:'/pages/mains/tasks/tasks'
					})
				}
			},
			
		}
	}
</script>

<style scoped lang="scss">
	.mains {
		.heads{
			position: absolute;
			z-index: 1;
			top: 0;
			right: 0;
			background: url('https://z1.ax1x.com/2023/11/15/piYa2fe.png') no-repeat;
			background-size: 100% 100%;
			width: 100%;
			height: 380rpx;
			
			.headmsg{
				padding: 100rpx 60rpx;
				font-size: 32rpx;
				font-weight: 500;
				color: #ffffff;
				.phone{
					font-size: 28rpx;
					margin-top: 15rpx;
				}
				image{
					width: 100rpx;
					height: 100rpx;
					border-radius: 50%;
					margin-right: 33rpx;
				}
			}
		}
		.contents{
			padding: 391rpx 11rpx 0 11rpx;
			border: 1px solid #EDEDED;
			border-radius: 10rpx;
			.cont{
				background: #ffffff;
				display: flex;
				align-items: center;
				padding: 20rpx 55rpx;
				font-size: 32rpx;
				font-family: PingFang SC;
				font-weight: bold;
				color: #000000;
				border-bottom: 1px solid #EDEDED;
				img{
					width: 40rpx;
					height: 50rpx;
					margin-right: 30rpx;
				}
			}
			
		}
	}
</style>